package day0401;

import java.util.Scanner;

public class MaxNum2 {
    /**
     * 2.[6 和 9 组成的最大数字]
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLine()) {
            int num = Integer.parseInt(sc.nextLine());
//            for (int i = 1000; i >= 1; i = i / 10) {
//                 int a = (num %(i *10))/i ;
//                if (a == 6) {
//                    num = num + 3 * i;
//                    break;
//                }
//            }
//            System.out.println(num);
            String s = String.valueOf(num);
            num = Integer.parseInt(s.replaceFirst( "6", "9"));
            System.out.println(num);
        }

    }
}
